package com.spring.ioc;

import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Configuration;

//@Configuration
//public class TestBean implements BeanFactoryPostProcessor {
//	/**
//	 * Modify the application context's internal bean factory after its standard
//	 * initialization. All bean definitions will have been loaded, but no beans
//	 * will have been instantiated yet. This allows for overriding or adding
//	 * properties even to eager-initializing beans.
//	 *
//	 * @param beanFactory the bean factory used by the application context
//	 * @throws BeansException in case of errors
//	 */
//	@Override
//	public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
//		System.out.println("容器初始化后，Spring 会调用 postProcessBeanFactory 方法");
//		BeanDefinition myJavaBean = beanFactory.getBeanDefinition("myJavaBean");
//		MutablePropertyValues propertyValues = myJavaBean.getPropertyValues();
//		System.out.println("属性值：" + propertyValues);
//		if (propertyValues.contains("name")) {
//			propertyValues.addPropertyValue("name", "wang wu");
//		}
//		myJavaBean.setScope(BeanDefinition.SCOPE_PROTOTYPE);
//	}
//}
